import java.util.Scanner;

public class TestDemo {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int i = 0;
        for (i = a-1; i < a ; i--) {
            if(a % i == 0 && b % i == 0 && i != 1 ){
                System.out.println(i);
                }
            }
        }
    }

